package leetcode.string;

public class Child {

    public static int strStr(String haystack, String needle) {
        if ("".equals(needle)){
            return 0;
        }
        char[] haystackchar = haystack.toCharArray();
        char[] needlechar = needle.toCharArray();
        boolean flag = false;
        for (int index = 0; index <= haystack.length() - needle.length(); index++) {
            if (haystackchar[index] == needlechar[0]) {
                boolean flag2 = true;
                for (int a = 0; a < needle.length(); a++) {
                    if (haystackchar[index + a] != needlechar[a]) {
                        flag2 = false;
                        break;
                    }
                }
                if(flag2){
                    flag = true;
                }
            }
            if (flag) {
                return index;
            }
        }
        return -1;



















    }

}
